package cn.chenhongchao.hospital.controller;

import cn.chenhongchao.hospital.common.api.CommonResult;
import cn.chenhongchao.hospital.service.IMedicineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: 啊超
 * @time: 2021/5/31 11:17
 */
@Api(value = "药房", tags = "药品管理接口")
@RestController
@CrossOrigin
@RequestMapping(value = "/drug")
public class MedicineController {

    @Resource
    private IMedicineService iMedicineService;

    @RequestMapping(value = "/list" ,method = RequestMethod.GET)
    public CommonResult getMap(){


        return CommonResult.success(iMedicineService.list());


 }

    @ApiOperation(value = "根据ID获取药品", notes = "传入 drug的ID")
    @RequestMapping(value = "/medicineById/{id}", method = RequestMethod.GET)
    public CommonResult getDrugById(@PathVariable Long id){


        return CommonResult.success(iMedicineService.getMedicineById(id));


    }
    @ApiOperation(value = "模糊查询 返回药品信息", notes = "传入 drug的模糊名字")
    @RequestMapping(value = "/medicineByName/{drugName}", method = RequestMethod.GET)
    public CommonResult getDrugByName(@PathVariable String drugName){


        return CommonResult.success(iMedicineService.getMedicineByName(drugName));


    }


}
